#include <QWidget>

class CToastBox : public QWidget
{
public:
	static void Info(QWidget* parent, const QString& title, const QString& content, bool modal = false);
	static void Warn(QWidget* parent, const QString& title, const QString& content, bool modal = false);
	static void Error(QWidget* parent, const QString& title, const QString& content, bool modal = false);
	static void Success(QWidget* parent, const QString& title, const QString& content, bool modal = false);

	static inline void EnableIcon(bool flag) { Enable_icon_ = flag; }
	static inline void EnableTitle(bool flag) { Enable_title_ = flag; }
	static inline void EnableMask(bool flag) { Enable_mask_ = flag; }
	static inline void SetAlpha(int alpha) { Alpha_ = alpha; }
	static inline void SetTimeout(int timeout) { Timeout_ = timeout; }

protected:
	enum EToastBoxType {
		EToastBoxType_Info,
		EToastBoxType_Warn,
		EToastBoxType_Error,
		EToastBoxType_Success
	};

	CToastBox() = default;
	CToastBox(EToastBoxType type, QWidget* parent, const QString& title, const QString& content, bool modal = false);
	~CToastBox() = default;

	// imp
	void timerEvent(QTimerEvent *event) override;
	void paintEvent(QPaintEvent *event) override;
	void mousePressEvent(QMouseEvent *event) override;
	void showEvent(QShowEvent *event) override;
	void closeEvent(QCloseEvent *event) override;
	bool eventFilter(QObject *watched, QEvent *event) override;

private:
	static bool		Enable_icon_;
	static bool		Enable_title_;
	static bool		Enable_mask_;
	static int		Alpha_;
	static int		Timeout_;

	QWidget*		parent_;
	EToastBoxType	type_;
	QString			title_;
    QString			content_;
	bool			auto_close_;
	QPixmap			icon_;
};

